<div class="content">
<h1>翡翠种色管理</h1>
<% form_for([:admin , @color] , :html=> {:class => 'form'}) do |f| %>
  <%= f.error_messages %>
  <p>
    名称：
    <%= f.text_field :name %>
    描述：
    <%= f.text_field :description %>
    <%= f.submit '添加' ,:class =>'button' %>
  </p>
<% end %>
        
<table class="table">
  <tr>
    <th>顺序</th>
    <th>名称</th>
    <th>排序</th>
    <th>描述</th>
    <th>操作</th>
  </tr>
  
  <% @colors.each do |color| %>
    <tr>
      <td><%=h color.sort %></td>
      <td><%=h color.name %></td>
      <td><%=h color.description %></td>
      <td>
        <%= link_to_remote((image_tag "/images/sort_up.jpg" ,:size => "10x15"),:url=>color_sort_ajax_path(:color_id => color.id,:sort => "up"),:method => :get,:before => "disabled_page('true');",:complete => "disabled_page('false');")%>
        <%= link_to_remote((image_tag "/images/sort_down.jpg",:size => "10x15"),:url=>color_sort_ajax_path(:color_id => color.id,:sort => "down"),:method => :get,:before => "disabled_page('true');",:complete => "disabled_page('false');") %>
      </td>
      <td>
          <%= link_to_function '修改', "$('color#{color.id}').toggle()" %>|
      <%= link_to '删除', admin_color_path(color), :confirm => 'Are you sure?', :method => :delete %></td>
    </tr>
    
    
      <% form_for([:admin ,color], :html=> {:class => 'form'}) do |f| %>
    
        <tr id="color<%=  color.id %>" style ='display:none' class = 'form'>
        <td><%=h color.sort %></td>
        <td>
          <%= f.text_field :name,:class =>'text_field' , :size => 3 %>
        </td>      
        <td>
          <%= f.text_field :description,:class =>'text_field'  , :size => 3 %>
        </td>
        <td>
          <%= f.submit '修改' ,:class =>'button' %>  
        </td>
      </tr>
    <% end %>
  <% end %>
</table>

<br />
</div>